#include "plugin_meta.h"
#include <iostream>

using namespace OHOS::Media::Plugin;

#define CHECK(x) ((x)? (void)(0) : (void(fprintf(stdout, "Failed at %d:%s: %s\n", __LINE__, __FILE__, #x)), std::exit(EXIT_FAILURE)))

template<const char* msg>
void display()
{
    std::cout << msg << std::endl;
}

// Why constexpr is enough? Does it have external linkage?
constexpr char str2[] = "Test 2";    // (2)
template<const char* tag>
        inline typename std::enable_if<(tag == str2), bool>::type
        display2()
        {
            std::cout << tag << " is true" << std::endl;
            return true;
        }

extern int test_meta2();

int main()
{
    display<str2>();    // (2')
    display2<str2>();    // (2')

    Meta meta;
    meta.Set<Key::STR_KEY_1>(10);
    uint32_t val;
    CHECK(meta.Get<Key::STR_KEY_1>(val));
    CHECK(val == 10);

    meta.Set<Key::STR_KEY_2>("hello");
    std::string val2;
    CHECK(meta.Get<Key::STR_KEY_2>(val2));
    CHECK(val2 == "hello");

    test_meta2();
    return 0;
}